﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace IceCS.DataStructure.BankCall
{
    public class BankCallService
    {
        public IBankQueue BankQueue { get; set; }
        public BankCallService(IBankQueue bankQueue)
        {
            BankQueue = bankQueue;
        }
        public void Service()
        {
            while (true)
            {
                Thread.Sleep(10000);
                //Task.Delay(10000).Wait();//10s
                if (BankQueue.IsEmpty)
                {
                    continue;
                }
                lock (BankQueue)
                {
                    Console.WriteLine($"\n请{BankQueue.Dequeue()}号到{Thread.CurrentThread.ManagedThreadId}号窗口！");
                }
            }
        }
    }
}
